#include <iostream>
#include <string>
#include <vector>
using namespace std;
class Solution {
public:
    bool exist(vector<vector<char>>& board, string word) {
        int i = 0;
        int j = 0;
        int numRow = board.size();
        if(numRow == 0)
            return false;
        int numCol = board[0].size();
        if(numCol == 0)
            return false;
        while(i < numRow)
        {
            while(j < numCol)
            {
                bool result = test(i, j, numCol, numRow, board, word);
                if(result == true)
                    return true;
                j++;
            }
            i++;
        }
        return false;
    }
    bool test(int i, int j, int numCol, int numRow, vector<vector<char>>& board, string remWord)
    {
        if(remWord.size() == 0)
            return true;
        if(i >= numRow || j >= numCol || i < 0 || j < 0)
            return false;
        if(board[i][j] == remWord[0])
        {
            int temp = board[i][j];
            bool signal = true;
            board[i][j] = '0';
            remWord = string(remWord, 1);
            if( signal = !test(i + 1, j, numCol, numRow, board, remWord) )
                if( signal = !test(i, j + 1, numCol, numRow, board, remWord) )
                    if( signal = !test(i - 1, j, numCol, numRow, board, remWord) )
                        signal = !test(i - 1, j - 1, numCol, numRow, board, remWord);
            board[i][j] = temp;
            if( !signal )
                return !signal;
        }
        return false;
    }
};

int main()
{
    vector<vector<char>> board({{'A','B','C','E'},{'S','F','C','S'}});

    cout<<"asd";
}
